import Vue from "vue";
import VueRouter from "vue-router";
/**
 * 重写路由的push方法
 */
const routerPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error => error)
}

const Login = () => import("../views/login.vue");
const Home = () => import("../views/home.vue");
const ProjectManage = () => import("../views/menu/projectManage");
const PersonManage = () => import("../views/menu/personManage");
const ThemeManage = () => import("../views/menu/themeManage");

Vue.use(VueRouter);

const routes = [
  {
    path: "/login",
    name: "login",
    component: Login
  }, {
    path: "/",
    name: "home",
    component: Home,
    children: [
      {
        path: '/projectManage',
        name: 'projectManage',
        component: ProjectManage
      },
      {
        path: 'personManage',
        name: 'personManage',
        component: PersonManage
      },
      {
        path: 'themeManage',
        name: 'themeManage',
        component: ThemeManage
      }
    ]
  },
];

const router = new VueRouter({
  routes
});

export default router;
